 /*
 * @Author: 刘庆州 
 * @Date: 2022-03-14 17:11:07 
 * @Last Modified by: 刘庆州
 * @Last Modified time: 2022-03-15 10:20:59
 */


import HttpUtils from '../utils/HttpUtil'

import UserManager from '../common/UserManager'
import Constants from '../common/Constants'
 
 /**
 * 获取信息
 * @param params {userInfo}
 * @returns {Promise<any | never>}
 */
  const getTidInfo =async (tid) => {

    console.log("getTidInfo call")

    var userInfo = await UserManager.getUserInfo()
    const ticket = await UserManager.getLongTicket()
    const contextParam = {
      InvOrgId: userInfo.InvOrg,
      Ticket: ticket === null ? '' : ticket,
    };
    const parameters = [{
      'Value': tid,
    }];
  
    const params = {
      ApiType: 'SiteRegistrationCommonController',
      Context: contextParam,
      Method: 'GetTieInfo',
      Parameters: parameters,
  
    };
  
    
  
      console.log(params);
      return HttpUtils.POST('/Server.svc/api/invoke', params)
        .then(resp => {
          return Promise.resolve(resp);
        })
        .catch(resp => {
          // Toast.showToast(resp);
          return Promise.reject(resp);
        });
    };

    /**
 *  绑定RFID
 * @param params {userInfo}
 * @returns {Promise<any | never>}
 */
  const bindTieRfid = async (tid,rfid) => {

    var userInfo = await UserManager.getUserInfo()
    const ticket = await UserManager.getLongTicket()
    const contextParam = {
      InvOrgId: userInfo.InvOrg,
      Ticket: ticket === null ? '' : ticket,
    };
    const parameters = [{
      'Value': tid,
    },{
        'Value': rfid,
      }];
  
    const params = {
      ApiType: 'SiteRegistrationCommonController',
      Context: contextParam,
      Method: 'BindTieRfid',
      Parameters: parameters,
  
    };
  
    
  
      console.log(params);
      return HttpUtils.POST('/Server.svc/api/invoke', params)
        .then(resp => {
          return Promise.resolve(resp);
        })
        .catch(resp => {
       
          return Promise.reject(resp);
        });
    };



    module.exports = {
        getTidInfo,bindTieRfid
    
      };